{extend name="public/base" /}

{block name="title"}<title>公告发布</title>{/block}

{block name="pjax_container"}
<style>


    .content-header>.breadcrumb>li {
        color: #999;
    }

    .content-header>.breadcrumb>.active {
        color: #666;
    }

    .content-header {
        height: 51px;

    }

    .btn-primary {
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        margin-left: 0;
        padding: 5px 10px;
    }

    .box-primary {
        border-top-color: #ecf0f5 !important;
        border-top-width: 16px;

    }

    .btn-primary:hover {
        background-color: #1890FF;
        color: #fff;
        border: none;
        opacity: .9;
        border-radius: 6px !important;
    }

    .delete-one {
        background-color: ff4141 !important;
        margin-left: 15px;
        border-radius: 6px;
    }

    .sreachs {
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        margin-left: 15px;
        padding: 7px 15px;
    }

    .nav-tabs-custom {
        margin-bottom: 20px;
        background: #fff;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
        border-radius: 3px;
        margin-top: 16px;
    }

    tr>th,
    td {
        text-align: center;
    }


    .xzrw{
        height: 34px;
        margin-top: 3px;
        line-height: 24px;
        margin-left: 10px;
    }
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>任务大厅</li>
        <li class="active">公告发布</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                {include file="form_search/search_notice" /}
                <div class="box-header with-border" style="padding: 0;padding-left: 10px;">
                    <div class="pull-left">
                        <a href="{:url('issue')}" class="btn btn-sm task_nav_an"><i class="fa fa-save"></i> 任务发布</a>
                        <a href="{:url('issue_notice')}" class="btn btn-sm task_nav_an  task_nav_an_active"><i class="fa fa-save"></i> 公告发布</a>
                    </div>
                    
                    <a href="{:url('issue_notice_edit')}" class="btn btn-sm btn-primary xzrw"><i class="fa fa-save"></i> 新增</a>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th>任务名称</th>
                            <th>初审人</th>
                            <th>终审人</th>
                            <th>截止时间</th>
                            <th>阅读奖分</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        {volist name="$list" id="v"}
                        <tr>
                            <td>
                                {if condition="$v.check_status eq 2"}
                                    <!--<span style="color:red;">驳</span>-->
                                    <span style="color:red; font-size:11px; border-radius: 50%;border:1px solid red;width: 17px; height: 16px; display: inline-block;">驳</span>
                                {/if}
                                <a href="{:url('task/notice_info',['id'=>$v.id])}">{$v["name"]}</a>
                            </td>
                            <td>{$v["b_name"]}</td>
                            <td>{$v["c_name"]}</td>
                            <td>{:date('Y-m-d H:i:s',$v["end_time"])}</td>
                            <td>{$v["read_integral"]}分</td>
                            <td>
                                {if condition="$v.status eq 0"}
                                待初审
                                {elseif condition="$v.status eq 1"}
                                待终审
                                {elseif condition="$v.status eq 2"}
                                公示中
                                {elseif condition="$v.status eq 3"}
                                已截止
                                {elseif condition="$v.status eq 4"}
                                拟稿
                                {/if}
                            </td>
                            <td>
                                {if condition="$v.status == 4 && $v.record_user_id == $user_id"}
                                {:authAction("/".MODULE_NAME."/".CONTROLLER_NAME.'/notice_edit','edit',["id"=>$v["id"]])}
                                <form class="form-horizontal" style="display: inline-block" method="POST"
                                    action="{:url('notice_sub')}" onsubmit="return false">
                                    <input name="id" value="{$v.id}" type="hidden">
                                    <input id="first_check_user_id" value="{$v.first_check_user_id}" data="{$user_id}"
                                        type="hidden">
                                    <input name="check_opinion" id="check_opinion" value="" type="hidden">
                                    <button type="submit"
                                        class="btn btn-sm btn-primary audit_sub_submit" data-ruser="{$v.record_user_id}" data-fuser="{$v.first_check_user_id}"><i class="fa fa-save"></i>
                                        提交</button>
                                    <button class="submits hidden"></button>
                                </form>
                                {:authAction("/".MODULE_NAME."/".CONTROLLER_NAME.'/notice_edit','audit_del',["id"=>$v["id"]])}
                                {/if}
                                {if condition="$v.status == 0 && $v.record_user_id == $user_id"}
                                <a class='btn btn-primary notice_withdraw' href='javascript:;' data-id="{$v.id}" data-url="{:url('notice_withdraw')}"> 撤回</a>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function () {
        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });
</script>
<!-- 拟稿提交按钮触发弹窗 -->
<script>
    $(".audit_sub_submit").on('click',function () {
        console.log(222);
        var item = $(this);
        var ruser_id = item.attr('data-ruser');
        var fuser_id = item.attr('data-fuser');
        // console.log(item);
        if(fuser_id != ruser_id){
            console.log(111);
            item.parents(".form-horizontal").find(".submits").click();
        }else{
            console.log(222);
            $('#myModal2').modal('show');
            $("#tips_submit").click(function () {
                var check_opinion = $("#check_opinion_textarea").val();
                item.parents(".form-horizontal").find(".check_opinion").val(check_opinion);
                item.parents(".form-horizontal").find(".submits").click();
                $('#myModal2').modal('hide');
            });
        }
        return false;
    });
</script>
<!-- 拟稿提交按钮触发弹窗DOM结构 -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
    <div class="modal-dialog" role="document">
        <div class="modal-content move">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">提示</h4>
            </div>
            <div class="modal_body" style="width: 100%;padding: 20px;">
                <label style="width: 100%;margin: 0;">
                    请填写您的初审意见：
                    <textarea name="check_opinion_textarea" id="check_opinion_textarea" cols="45" rows="5"
                        style="display: block;width: 100%;max-height: 100px; margin:0;padding: 10px;border-radius: 5px;"
                        placeholder="可以输入一千字"></textarea>
                </label>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="tips_submit">确认</button>
            </div>
        </div>
    </div>
</div>
<script>
    $('.notice_withdraw').on('click',function () {
        if (!confirm("确定撤回？")){return false}
        var url = $(this).attr('data-url');
        var id = $(this).attr('data-id');
        var url1= "{:url('issue_notice')}";
        $.ajax({
            url:url,
            type:'post',
            data:{id:id},
            success:function (res) {
                $.amaran({'message':res.msg});
                if(res.err == 0){
                    $.pjax({'url': url1, container: '#pjax-container', fragment:'#pjax-container'})
                }
            }
        })
    })
</script>
{/block}